package 作业;

import java.util.Arrays;
import java.util.Scanner;

public class 奇数偶数排列02 {
    public static void main(String[] args) {

        //创建输入数组对象
        Scanner scanner = new Scanner(System.in);

        //定义数组长度
        int l = scanner.nextInt();

        //定义原数组和排序数组
        int [] arr = new int[l];

        //输入数组元素并打印
        for (int i = 0; i < arr.length; i++) {

            arr[i] = scanner.nextInt();

        }
        System.out.println(Arrays.toString(arr));

        int l1 = 0;
        int l2 = 0;

        //判断奇数偶数数组长度
        for (int i = 0; i < arr.length; i++) {

            if (arr[i] % 2 != 0){
                l1++;
            }else{
                l2++;
            }
        }

        int a = 0;//用于奇数数组赋值
        int b = 0;//用于偶数数组赋值
        int [] arr1 = new int[l1];//奇数数组
        int [] arr2 = new int[l2];//偶数数组

        //赋值操作
        for (int i = 0; i < arr.length; i++) {

            if (arr[i] % 2 != 0){

                arr1[a] = arr[i];
                a++;

            }else{

                arr2[b] = arr[i];
                b++;
            }

        }

        //将两个数组一起打印
        System.out.print("[");

        for (int i = 0; i < arr1.length; i++) {

            System.out.print(arr1[i] + ", ");

        }
        for (int i = 0; i < arr2.length ; i++) {

            System.out.print(arr2[i]);

            if (i < arr2.length-1) {

                System.out.print(", ");
            }
        }
        System.out.print("]");

    }
}
